package pers.mihao.quickstream.common.task.domain.runner;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import pers.mihao.quickstream.common.task.constans.TaskType;
import pers.mihao.quickstream.common.task.dto.JobParams;
import pers.mihao.quickstream.common.task.service.AutomaticTaskInvoker;
import pers.mihao.quickstream.common.util.spring.SpringUtil;


/**
 * @author mihao
 * @since 2024/11/17
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class JavaAutomaticTaskRunner extends AbstractAutomaticTaskRunner {

    private Class<? extends AutomaticTaskInvoker<?>> taskInvoke;

    private JobParams jobParams;

    @Override
    public TaskType taskType() {
        return TaskType.JAVA;
    }

    @Override
    public boolean doTask() {
        AutomaticTaskInvoker<JobParams> automaticTaskInvoker = (AutomaticTaskInvoker<JobParams>) SpringUtil.getBean(taskInvoke);
        return automaticTaskInvoker.doAutomaticTask(jobParams);
    }


}
